package version1

import (
	"server/global"
	operatemodel "server/model/operate"
	"server/myutils"
	"strconv"

	"github.com/gin-gonic/gin"
)

//@Summary 获取所有用户数据
//@Router /v1/getalluser [get]
//@Tags Gets
//@Description 普通管理员即可获取
//@Produce json
//@Accept json
//@Success 200 {object} model.StandardResponse{} `接口被正确调用,但是调用结果看status状态码`
func GetAllUser(req *gin.Context) {
	code, data := operatemodel.Getalluser()
	if code != global.SUCCESS {
		myutils.ResultJSON(req, code, nil)
		return
	}
	myutils.ResultJSON(req, code, data)
}

func DeleteUser(req *gin.Context) {
	s := req.Param("id")
	i, err := strconv.Atoi(s)
	if err != nil {
		myutils.ResultJSON(req, global.ERROR_FORMAT, nil)
		return
	}
	myutils.ResultJSON(req, operatemodel.Deleteuser(i), nil)
}
